package com.c.ctgproject.ui.production.doing

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.c.ctgproject.base.CTGproject
import com.c.ctgproject.base.BaseViewModel
import com.c.ctgproject.entity.ResultEntity
import com.c.ctgproject.http.ApiMethods
import com.c.ctgproject.utils.commonAwaitSync
import com.c.ctgproject.utils.handlerNull
import com.c.ctgproject.utils.launch
import com.c.ctgproject.utils.userToken
import okhttp3.MultipartBody
import okhttp3.RequestBody

class DoingProductionViewModel : BaseViewModel() {
    private val mUpFile = MutableLiveData<ResultEntity<*>>()
    val upFile: LiveData<ResultEntity<*>> get() = mUpFile

    fun upFile(carId: RequestBody,enterPic: MultipartBody.Part) {
        launch({
            mUpFile.value=ApiMethods.getApiService().confirmReceipt(userToken,carId,enterPic).commonAwaitSync()
        }, {
            mError.value=it.message.handlerNull()
        })
    }
}